{extend name="common/base"}
{block name="title"}首页{/block}
<style>
    #ajax-page a {cursor: pointer}
</style>
{block name="content"}
        <!-- 内容区域 -->
        <div class="tpl-content-wrapper">
            <div class="row-content am-cf">
                <div class="row">
                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf">
                            <div class="widget-head am-cf">
                                <div class="widget-title  am-cf">商品列表</div>


                            </div>
                            <div class="widget-body  am-fr">
                                <div class="am-u-sm-12">
                                    <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black ">
                                        <thead>
                                            <tr>
                                                <th>商品id</th>
                                                <th>商品缩略图</th>
                                                <th>商品名称</th>
                                                <th>价格</th>
                                                <th>规格</th>
                                                <th>积分</th>
                                                <th>销量</th>
                                                <th>库存</th>
                                                <th>上架状态</th>
                                                <th>操作</th>
                                            </tr>
                                        </thead>
                                        <tbody id="ajax-body">
                                            {volist name="list" id="val" key="v"}
                                            <tr class="gradeX">
                                                <td class="am-text-middle">{$v}</td>
                                                <td>
                                                    {volist name="val['thumb_src']" id="thumb_src"}
                                                    <img src="{$thumb_src}" class="tpl-table-line-img" alt="">
                                                    {/volist}
                                                </td>
                                                <td class="am-text-middle" style="overflow: hidden;text-overflow:ellipsis;
white-space: nowrap;">{$val.name}</td>
                                                <td class="am-text-middle">¥{$val.price}</td>
                                                <td class="am-text-middle">{$val.guigeType_name}</td>
                                                <td class="am-text-middle">{$val.jifen}</td>
                                                <td class="am-text-middle">{$val.sale}</td>
                                                <td class="am-text-middle">{$val.kucun}</td>
                                                <td class="am-text-middle">
                                                    <div class="tpl-table-black-operation">
                                                        <button class="tpl-table-black-operation-del" onclick="get_onsale(this)" style="color:red;border-radius:15px;outline-color:transparent;">{$status[$val.is_onsale]}</button>                                                        
                                                        <input type="hidden" id="get_attributes_id" value="{$val.attributes_id}">
                                                    </div>
                                                </td>
                                                <td class="am-text-middle" width="10%">
                                                    <div class="tpl-table-black-operation">
                                                        <a href="{:Url('/admin/goods/good_edit')}?attributes_id={$val.attributes_id}">
                                                            <i class="am-icon-pencil"></i> 编辑
                                                        </a>
                                                    </div>
                                                </td>
                                            </tr>
                                            {/volist}
                                        </tbody>
                                    </table>
                                </div>
                                <div class="am-u-lg-12 am-cf">

                                    <div class="am-fr" id="ajax-page">
                                        {$page}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
<script>
function get_onsale(obj){
    var attributes_id = $(obj).next('input').val();
    $.ajax({
        url:"{:Url('admin/Goods/get_onsale')}",
        type:"post",
        data:{attributes_id:attributes_id},
        dataType:"json",
        success:function(data){
            console.log(data);
            if(data==0){
                $(obj).html('未上架');
            }else{
                $(obj).html('已上架');
            }
        }
    });
}
</script>
{/block}